from dashscope import Generation

def call_qwen_model(prompt,input_content):
    messages = [
        {'role': 'system', 'content': prompt},
        {'role': 'user', 'content': input_content}
    ]
    response = Generation.call(
        # 若没有配置环境变量，请用百炼API Key将下行替换为：api_key = "sk-xxx",
        api_key="",
        model="",   # 模型列表：https://help.aliyun.com/zh/model-studio/getting-started/models
        messages=messages,
        result_format="message"
    )

    if response.status_code == 200:
        res = response.output.choices[0].message.content
        return True,res
    else:
        print(f"HTTP返回码：{response.status_code}")
        print(f"错误码：{response.code}")
        print(f"错误信息：{response.message}")
        print("请参考文档：https://help.aliyun.com/zh/model-studio/developer-reference/error-code")
        return False,None